// matrix multiplication

# include <iostream>
using namespace std;

class MatrixMultiplier {
  int rowA, colA, rowB, colB, i, j;
  int a[10][10], b[10][10], c[10][10];
public:
  void get();
  void multiply();
  void display();
};

void MatrixMultiplier::get() {
  cout << "Enter rows for first matrix: ";
  cin >> rowA;
  cout << "Enter columns for first matrix (rows for second matrix): ";
  cin >> colA;
  rowB = colA;
  cout << "Enter columns for second matrix: ";
  cin >> colB;
  cout << "\n";
  for(i = 0; i < rowA; i++) {
    for(j = 0; j < colA; j++) {
      cout << "Enter element [" << i+1 << ", " << j+1 << "] for matrix A: " ;
      cin >> a[i][j];
    }
  }
  cout << "\n";
  for(i = 0; i < rowB; i++) {
    for(j = 0; j < colB; j++) {
      cout << "Enter element [" << i+1 << ", " << j+1 << "] for matrix B: " ;
      cin >> b[i][j];
    }
  }
}

void MatrixMultiplier::multiply() {
  int k =0;
  for(i = 0; i < rowA; i++) {
    for(j = 0; j < colB; j++) {
      c[i][j] = 0;
      for(k = 0; k < rowB; k++) {
        c[i][j] += a[i][k] * b[k][j];
      }
    }
  }
}

void MatrixMultiplier::display() {
  cout << "\n";
  for(i = 0; i < rowA; i++) {
    for(j = 0; j < colB; j++) {
      cout << "\t" << c[i][j];
    }
    cout << "\n";
  }  
}

int main() {
  MatrixMultiplier mm;
  mm.get();
  mm.multiply();
  mm.display();
}
